
#include "Tick.h"
#include "Log.h"

namespace yet{


Tick::Tick(bool autoPrint_):tickStart(0), tickEnd(0), autoPrint(autoPrint_)
{
	Start();
}

Tick::~Tick(void)
{
	if(autoPrint){
		End("");
	}
}
void Tick::Start(){
	tickStart = ::GetTickCount();
}
long Tick::End(const char* prefix){
	autoPrint = false;
	tickEnd = ::GetTickCount();
	long tick = tickEnd - tickStart;
	;
	if(prefix){
		Log<<"[Tick] "<<prefix<<":"<<tick<<endl;
	}else{
		Log<<"[Tick] "<<tick<<endl;
	}
	return tick;
}
}
